using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SIOGDE.AccesoDatos.Entidades;
using SIOGDE.Negocios;
using SIOGDE.Negocios.Servicios;
using Didsoft.Mvc.DataModel;
using Didsoft.Mvc.Controller;

namespace SIOGDE.Web.Controllers
{
    public class SmtpConfigController : BaseController<SmtpConfig>
    {
	    #region interface servicios SmtpConfig

		private ISmtpConfigNegociosServicio servicio = null;

		#endregion
				
		#region constructor and overridable

        public SmtpConfigController()
        {
		    servicio = new SmtpConfigNegocios();
            base.SetDataModelService(servicio);            
        }

		#endregion

		#region	actions

		[HttpGet]
		public override ActionResult Index()
        {
            return RedirectToAction("FilterList");
        }

        [HttpPost]
        public JsonResult SendTestEmail()
        {           
            try
            {
                servicio.SendTestEmail();
                return Json(new { Result = "OK", Record = "SENT" });
            }
            catch (Exception ex)
            {
                return Json(new { Result = "ERROR", Message = ex.InnerException!=null?ex.InnerException.Message:ex.Message });
            }
       
        }

		#endregion
        
    }
}

